﻿using System.Collections.Generic;

namespace SocketCore.Decoder
{
    public class MessageDecoderFactory
    {
        private Dictionary<int, IMessageDecoder> decoders = new Dictionary<int, IMessageDecoder>(5);
        private static MessageDecoderFactory instance = new MessageDecoderFactory();

        private MessageDecoderFactory()
        {
            decoders.Add(0, new ManualMessageDecoder());
        }

        public static MessageDecoderFactory Instance
        {
            get { return instance; }
        }

        public IMessageDecoder GetMessageDecoder(int type)
        {
            return this.decoders[type];
        }

        public void RegisterDecoder(int type, IMessageDecoder decoder)
        {
            this.decoders.Add(type, decoder);
        }
    }

 

}
